#include <iostream>

using namespace std;

int main_42()
{
    int n,start;
    cin>>n;
    int matrix[n][n];
    for (int i=0; i<n ; i++ )
    {
        for (int j=0; j<n ; j++ )
        {
            cin>>matrix[i][j];
        }
    }
    for (int i=0; i<n ; i++ )
    {
        if (i%2==1)
        {
            for (int j=0; j<=i ; j++ )
            {
                printf("%d ",matrix[j][i-j]);
            }
        }
        else
        {
            for (int j=0; j<=i ; j++ )
            {
                printf("%d ",matrix[i-j][j]);
            }

        }
    }
    start=1;
    for (int i=n; i<=2*(n-1) ; i++ )
    {
        if (i%2==1)
        {
            for (int j=start; j<=(i-start) ; j++ )
            {
                printf("%d ",matrix[j][i-j]);
            }
        }
        else
        {
            for (int j=start; j<=(i-start) ; j++ )
            {
                printf("%d ",matrix[i-j][j]);
            }
        }
        start++;
    }
    return 0;
}
